"use strict";
/**
 * @ Author: Yoann Meclot. MSay2
 * @ Created on: 2021-06-14 18:11:24
 * @ Modified on: 2021-06-14 18:11:59
 */
/**
 * Copyright (c) 2020-2021 MSay2 (Yoann Meclot) - @msay2/tspoet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to set private field on non-instance");
    }
    privateMap.set(receiver, value);
    return value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to get private field on non-instance");
    }
    return privateMap.get(receiver);
};
var _mName;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Modifier = void 0;
const Objects_js_1 = require("../util/Objects.js");
/**
 * The Modifier object is mean to specify a modifier to your element, field and/or method.
 *
 * The modifier is defined by one id, use static field to insert a specific modifier to your element, field and/or method.
 *
 * @class `Modifier`
 * @version 1.2
 */
class Modifier {
    constructor(name) {
        _mName.set(this, void 0);
        __classPrivateFieldSet(this, _mName, name);
    }
    /**
     * Check if the modifiers list is conform for a contructor.
     * @param list The modifiers list.
     * @type {boolean}
     * @since 1.2
     */
    static isConstructor(list) {
        for (let entry of list.entries()) {
            switch (entry.getValue()) {
                case this.PUBLIC:
                case this.PROTECTED:
                case this.PRIVATE:
                case this.UNDEFINED:
                    return true;
            }
        }
        return false;
    }
    /**
     * Check if the modifiers list contain basic TypeScript modifiers.
     *
     * @param list The modifiers list.
     * @type {boolean}
     * @since 1.2
     */
    static isSimpleModifier(list) {
        for (let entry of list.entries()) {
            switch (entry.getValue()) {
                case this.EXPORT:
                case this.UNDEFINED:
                    return true;
                default:
                    return false;
            }
        }
        return false;
    }
    /**
     * Check if the modifiers list contain a valid modifiers for nested classes.
     *
     * @param list The modifiers list.
     * @type {boolean}
     * @since 1.2
     */
    static isNestedClass(list) {
        for (let entry of list.entries()) {
            switch (entry.getValue()) {
                case this.PRIVATE:
                case this.PUBLIC:
                case this.UNDEFINED:
                    return true;
                default:
                    return false;
            }
        }
    }
    /**
     * Check if the modifiers list contain `private` modifier.
     *
     * @param list The modifiers list.
     * @type {boolean}
     * @since 1.2
     */
    static isPrivate(list) {
        for (let entry of list.entries()) {
            switch (entry.getValue()) {
                case this.PRIVATE:
                    return true;
                default:
                    return false;
            }
        }
    }
    equals(object) {
        if (Objects_js_1.Objects.isNull(object))
            return false;
        if (object == this)
            return true;
        if (object instanceof Modifier)
            return __classPrivateFieldGet(this, _mName) == __classPrivateFieldGet(object, _mName);
        return false;
    }
    /**
     * Get id.
     *
     * @type {number}
     * @since 1.2
     */
    getName() {
        return __classPrivateFieldGet(this, _mName);
    }
    /**
     * Get name by the current id.
     *
     * @type {string}
     * @since 1.2
     */
    getSimpleName() {
        switch (__classPrivateFieldGet(this, _mName)) {
            case 0: return "export";
            case 1: return "public";
            case 2: return "static";
            case 3: return "private";
            case 4: return "abstract";
            case 5: return "protected";
            case 6: return "readonly";
            default:
                return "";
        }
    }
}
exports.Modifier = Modifier;
_mName = new WeakMap();
/**
 * EXPORT modifier.
 * @type {Modifier}
 * @since 1.2
 */
Modifier.EXPORT = new Modifier(0);
/**
 * PUBLIC modifier.
 * @type {Modifier}
 * @since 1.2
 */
Modifier.PUBLIC = new Modifier(1);
/**
 * STATIC modifier.
 * @type {Modifier}
 * @since 1.2
 */
Modifier.STATIC = new Modifier(2);
/**
 * PRIVATE modifier.
 * @type {Modifier}
 * @since 1.2
 */
Modifier.PRIVATE = new Modifier(3);
/**
 * ABSTRACT modifier.
 * @type {Modifier}
 * @since 1.2
 */
Modifier.ABSTRACT = new Modifier(4);
/**
 * PROTECTED modifier.
 * @type {Modifier}
 * @since 1.2
 */
Modifier.PROTECTED = new Modifier(5);
/**
 * READONLY modifier.
 * @type {Modifier}
 * @since 1.2
 */
Modifier.READONLY = new Modifier(6);
/**
 * NOTHING modifier.
 * @type {Modifier}
 * @since 1.2
 */
Modifier.UNDEFINED = new Modifier(7);
//# sourceMappingURL=Modifier.js.map